import java.awt.event.MouseEvent;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Padda1
 */
public class ContextMenu extends JPopupMenu
{
    JMenuItem copy;
    JMenuItem cut;
    JMenuItem paste;
    JMenuItem close;
    
    boolean cutSelected;
    boolean copySelected;
    boolean pasteSelected;
    boolean closeSelected;
    
    public ContextMenu()
    {
        cutSelected = false;
        copySelected = false;
        pasteSelected = false;
        closeSelected = false;
        
        cut = new JMenuItem("Cut");
        copy = new JMenuItem("Copy");
        paste = new JMenuItem("Paste");
        close = new JMenuItem("Close");
        
        cut.addMouseListener(new java.awt.event.MouseAdapter() 
        {
            public void mouseClicked(java.awt.event.MouseEvent evt) 
            {
                cutMouseClicked(evt);
            }
            
            /**
            * BeforeTextArea Mouse.
            * @param evt 
            */
            private void cutMouseClicked(MouseEvent evt) 
            {
                if (evt.getButton() == MouseEvent.BUTTON3)
                {
                    cutSelected = true;
                }
            }
        });
        
        copy.addMouseListener(new java.awt.event.MouseAdapter() 
        {
            public void mouseClicked(java.awt.event.MouseEvent evt) 
            {
                copyMouseClicked(evt);
            }
            
            /**
            * BeforeTextArea Mouse.
            * @param evt 
            */
            private void copyMouseClicked(MouseEvent evt) 
            {
                if (evt.getButton() == MouseEvent.BUTTON3)
                {
                    copySelected = true;
                }
            }
        });
        
        paste.addMouseListener(new java.awt.event.MouseAdapter() 
        {
            @Override
            public void mouseClicked(java.awt.event.MouseEvent evt) 
            {
                pasteMouseClicked(evt);
            }
            
            /**
            * BeforeTextArea Mouse.
            * @param evt 
            */
            private void pasteMouseClicked(MouseEvent evt) 
            {
                if (evt.getButton() == MouseEvent.BUTTON3)
                {
                    pasteSelected = false;
                }
            }
        });
        
        close.addMouseListener(new java.awt.event.MouseAdapter() 
        {
            @Override
            public void mouseClicked(java.awt.event.MouseEvent evt) 
            {
                closeMouseClicked(evt);
            }
            
            /**
            * BeforeTextArea Mouse.
            * @param evt 
            */
            private void closeMouseClicked(MouseEvent evt) 
            {
                if (evt.getButton() == MouseEvent.BUTTON3)
                {
                    closeSelected = false;
                }
            }
        });
        
        add(cut);
        add(copy);
        add(paste);
        add(close);
    }//ContextMenu

    public boolean cut()
    {
        return cutSelected;
    }
    
    public boolean copy()
    {
        return copySelected;
    }
    
    public boolean paste()
    {
        return pasteSelected;
    }
    public boolean close()
    {
        return closeSelected;
    }
}
